#include "shm.hpp"
#include <unistd.h>
using namespace std;
int main()
{
    //1.创建共享内存的名字(标识符用以区分，已存在)
    key_t k=ftok(pathname,proj_id);
    //2.寻找共享内存
    int shmid=shmget(k,4096,IPC_CREAT);
    assert(shmid>=0);
    //3.使当前进程与共享内存联系起来
    char* address=(char*)shmat(shmid,NULL,0);
    assert(address);
    for(int i=0;i<50;i++)
    {
        cout<<address<<endl;
        sleep(1);
    }
    //4.与共享内存脱离
    shmdt(address);
    return 0;
}